<template>
  <p-card :bordered="false">
    <p-page-header
      style="border: 1px solid rgb(235, 237, 240); margin-bottom: 30px"
      title="工单在线维修-单据申请"
    >
      <template slot="extra">
        <!-- <p-popconfirm
          title="确定要提交吗？"
          ok-text="确定"
          cancel-text="取消"
          @confirm="submit_button"
          @cancel="cancel"
        > -->
        <p-button type="primary" @click="submit">提交</p-button>
        <!-- </p-popconfirm> -->
        <p-button @click="backToIndex">取消</p-button>
      </template>
    </p-page-header>
    <div class="table-page-search-wrapper">
      <p-collapse v-model="activeKey">
        <p-collapse-panel key="1" header="送修信息栏">
          <add-info ref="item"></add-info>
        </p-collapse-panel>
        <p-collapse-panel key="2" header="用户操作杂志" :disabled="false">
          <p>暂无信息</p>
        </p-collapse-panel>
      </p-collapse>
    </div>
  </p-card>
</template>

<script>
import AddInfo from "./addInfo";
import { postAction, getAction } from "@/api/manage";
export default {
  name: "",
  components: {
    AddInfo,
  },
  data() {
    return {
      activeKey: "1",
    };
  },
  mounted() {},
  methods: {
    backToIndex() {
      this.$emit("update:tags", true);
    },
    submit() {
      this.$refs.item.$refs.scanFormRules.validate((value) => {
        if (value) {
          const {
            billsForm,
            troubleForm,
            stationForm,
            scanForm,
            snPn,
          } = this.$refs.item;
          let params = {
            ...billsForm,
            smallFault: troubleForm.smallFault,
            bigFault: troubleForm.bigFault.badGroupCode,
            sendRepairProcess: stationForm.processTwoCode,
            sendRepairStation: stationForm.stationCode,
            snPn,
            linename: scanForm.linename,
            mcode: scanForm.mcode,
            mname: scanForm.mname,
            repairNumber: scanForm.repairNumber,
            productionBillno: scanForm.productionno,
            processBillno: scanForm.processbillno,
            classtimename: scanForm.classtimename,
          };
          console.log(billsForm, scanForm, params);
          postAction(
            "/mes-manufacture/mfOnlineRepairTask/addWithPriority",
            params
          ).then((res) => {
            if (res.success) {
              this.$message.success("单据申请成功");
              // this.backToIndex();
            } else {
              this.$message.error(res.msg);
            }
          });
        }
      });
    },
  },
};
</script>

<style lang='less'>
</style>
